//
//  shopDetailTableViewCell.m
//  jianpai
//
//  Created by yrapp on 16/1/15.
//  Copyright © 2016年 yrapp. All rights reserved.
//

#import "CartDetailTableViewCell.h"

@implementation CartDetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
//        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 5, kWidth, 110)];
//        backView.backgroundColor = [UIColor whiteColor];
//        backView.layer.shadowColor = [UIColor grayColor].CGColor;
//        backView.layer.shadowOffset = CGSizeMake(0, 0);
//        backView.layer.shadowOpacity = 1;
//        [self.contentView addSubview:backView];
        
        
        UIImageView *backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 110)];
        backImageView.image = [UIImage imageNamed:@"brand_item_background"];
        [self.contentView addSubview:backImageView];
        
        _shopImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 80, 90)];
        _shopImageView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_shopImageView];
        
        
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_shopImageView.frame.origin.x + 10 + _shopImageView.frame.size.width, 10, kWidth - 20 - _shopImageView.frame.origin.x - _shopImageView.frame.size.width, 30)];
        _titleLabel.font = [UIFont systemFontOfSize:11];
        _titleLabel.text = @"欧普照明四灯取暖浴霸正品 超薄换气三合一多功能卫生间传统吊顶";
        _titleLabel.numberOfLines = 0;
        //_titleLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_titleLabel];
        
        _detailsLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 5,_titleLabel.frame.size.width,30)];
        // _detailsLabel.backgroundColor = [UIColor grayColor];
        
        _detailsLabel.text = @"颜色分类:[普通吊顶] 流金岁月 取暖+照明+换气三合一/开孔30x30cm";
        _detailsLabel.numberOfLines = 0;
        _detailsLabel.font = [UIFont systemFontOfSize:11];
        _detailsLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_detailsLabel];
        
        
        _nowPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x,_detailsLabel.frame.origin.y + _detailsLabel.frame.size.height + 5, 40, 20)];
        _nowPriceLabel.textColor = [UIColor redColor];
        _nowPriceLabel.font = [UIFont systemFontOfSize:12];
        _nowPriceLabel.text = @"¥ 199";
        [self.contentView addSubview:_nowPriceLabel];
        
                //要自适应宽度
        _numbLabel = [[UILabel alloc] initWithFrame:CGRectMake(kWidth - 60, _nowPriceLabel.frame.origin.y, 40, 20)];
        _numbLabel.font = [UIFont systemFontOfSize:12];
        _numbLabel.textAlignment = NSTextAlignmentRight;
        _numbLabel.text = @"x 1";
        [self.contentView addSubview:_numbLabel];
        
    }
    
    return self;
    
}


- (void)setModel:(ShopModel *)model {
    
    self.titleLabel.text = model.title;
    self.nowPriceLabel.text = [NSString stringWithFormat:@"¥%@",model.price];
    [self.nowPriceLabel sizeToFit];
    [self.shopImageView sd_setImageWithURL:[NSURL URLWithString:model.pic_s] placeholderImage:nil];
    //self.detailsLabel.text = ;
    self.numbLabel.text = [NSString stringWithFormat:@"X %@",model.num];
    
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
